#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int maxSubArray(vector<int>& nums) {
        int n = nums.size();
        vector<int> dp(n + 1);
        int ret = INT_MIN;
        dp[0] = 0;
        for (int i = 1; i < n + 1; i++)
        {
            dp[i] = max(nums[i - 1], dp[i - 1] + nums[i - 1]);
            if (ret < dp[i])
            {
                ret = dp[i];
            }
        }
        return ret;

    }
};